package org.xbs.demo1.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.xbs.demo1.pojo.Video;
import org.xbs.demo1.result.Result;
import org.xbs.demo1.service.IVideoService;

import java.io.IOException;

@Slf4j
@RestController
@RequestMapping("/videos")
@CrossOrigin//括号内输入对应的前端地址
public class VideoController {
    @Autowired
    private IVideoService videoService;
    //上传视频的时候得等待视频上传完毕后再进行操作这个时候前端得做个类似进度条的东西并且禁止前端操作
    //只用传视频文件之后service层会加工后再存入数据库
    @PostMapping//上传视频的接口
    public Result uploadVideo(@RequestBody Video video) throws IOException {
        videoService.uploadVideo(video);
        return Result.success();
    }

}
